package com.gem.day05;

/**电脑实体类*/
public class Computer {
	private String brand;
	private double price;
	private String description;
	private Screen screen;

	public Computer() {

	}

	public Computer(String brand, double price, String description) {
		super();
		this.brand = brand;
		setPrice(price);
		this.description = description;
	}

	public Computer(String brand, double price, String description, Screen screen) {
		super();
		this.brand = brand;
		setPrice(price);
		this.description = description;
		this.screen = screen;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		if (price < 1000 || price > 20000) {
			this.price = 2000;
		} else {
			this.price = price;
		}
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Screen getScreen() {
		return screen;
	}

	public void setScreen(Screen screen) {
		this.screen = screen;
	}

	public String toString() {
		String result = "品牌:" + brand + ",价格: " + price + ",描述: " + description;
		//判断电脑对象中是否包含屏幕信息
		if (screen != null) {
			result += "\n" + screen;
		}
		return result;
	}
}
